package com.abo.yaas.view.widgets;

import com.abo.yaas.domain.Auction;
import com.abo.yaas.domain.Bid;
import com.abo.yaas.webservice.ResourceProvider;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.filter.Filters;
import com.vaadin.ui.Table;

@SuppressWarnings("serial")
public class BidTable extends Table {
    
    private final JPAContainer<Bid> container = new JPAContainer<Bid>(Bid.class);

    public BidTable() {
        super();
        setSizeFull();
        setPageLength(10);
        container.setEntityProvider(ResourceProvider.getEntityProvider(Bid.class));
        setContainerDataSource(container);
        setVisibleColumns(new Object[] { "amount", "userName", "time" });
    }

    public void updateAuction(final Auction auction) {
        container.removeAllFilters();
        container.addFilter(Filters.eq("auctionId", auction.getId()));
    }
}
